<template>
  <view class="category">
    <navigator
      :url="`/pages/home/imgCategory?id=${item.id}`"
      class="cata_item"
      v-for="item in categoryList"
      :key="item.id"
    >
      <image :src="item.cover" v-model="aspectFill"></image>
      <text>{{ item.rname }}</text>
    </navigator>
  </view>
</template>

<script>
export default {
  name: "",
  components: {},
  data() {
    return {
      categoryList: [],
    };
  },
  methods: {
    async getList() {
      const { data } = await this.$request({
        url: "http://157.122.54.189:9088/image/v1/vertical/category",
      });
      console.log(data);
      this.categoryList = data.res.category;
    },
  },
  created() {
    this.getList();
  },
  mounted() {
    //屏幕上方标题
    uni.setNavigationBarTitle({
      title: "分类",
    });
  },
};
</script>
<style scoped lang="scss">
.category {
  display: flex;
  flex-wrap: wrap;
  .cata_item {
    position: relative;
    flex: 30%;
    margin: 6rpx;
    image {
      height: 260rpx;
    }

    text {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      color: white;
      padding-left: 16rpx;
      /*  background-color: rgba(189, 179, 179, 0.7); */
      background-image: linear-gradient(
        left,
        rgba(102, 101, 101, 0.8),
        rgba(189, 179, 179, 0.6)
      );
    }
  }
}
</style>
